package controller

import (
	"context"
	"lot_admin_api/api"
	"lot_admin_api/internal/model"
	"lot_admin_api/internal/service"
)

var RechargeRule = cRechargeRule{}

type cRechargeRule struct{}

// AddRechargeRule  添加充值规则
func (h *cRechargeRule) AddRechargeRule(ctx context.Context, req *api.AddRechargeRuleReq) (res *model.RechargeRuleIdRes, err error) {
	id, err := service.RechargeRule().AddRechargeRule(ctx, req)
	res = &model.RechargeRuleIdRes{
		Id: id,
	}
	return res, err
}

// UpdateRechargeRule  更新充值规则
func (h *cRechargeRule) UpdateRechargeRule(ctx context.Context, req *api.UpdateRechargeRuleReq) (res *model.RechargeRuleIdRes, err error) {
	id, err := service.RechargeRule().UpdateRechargeRule(ctx, req)
	res = &model.RechargeRuleIdRes{
		Id: id,
	}
	return res, err
}

// DeleteRechargeRule  更新充值规则
func (h *cRechargeRule) DeleteRechargeRule(ctx context.Context, req *api.DeleteRechargeRuleReq) (res *model.RechargeRuleIdRes, err error) {
	id, err := service.RechargeRule().DeleteRechargeRule(ctx, req)
	res = &model.RechargeRuleIdRes{
		Id: id,
	}
	return res, err
}

// RechargeRuleInfo 通过id获取充值规则详情
func (h *cRechargeRule) RechargeRuleInfo(ctx context.Context, req *api.RechargeRuleInfoReq) (res *model.RechargeRuleDbRes, err error) {
	res, err = service.RechargeRule().SearchRechargeRule(ctx, req.Id)
	return res, err
}

// RechargeRuleList 获取通知充值规则列表
func (h *cRechargeRule) RechargeRuleList(ctx context.Context, req *api.RechargeRuleListReq) (res *model.RechargeRuleListRes, err error) {
	res, err = service.RechargeRule().RechargeRuleList(ctx, req.RechargeRuleListReq)
	return res, err
}
